package com.entity;

import com.util.GameUtil;

import java.awt.*;

/**
 * @author: Combo
 * @time: 2021/1/4 15:30
 * @description: 宠物
 */
public class Pet {
    private Image image;
    private Image[] images;
    public static final int WIDTH = 70;
    public static final int HEIGHT = 60;
    private Integer x;
    private Integer y;
    private Integer index = 0;

    public Pet() {
        init();
        image = images[0];
        x = 300;
        y = 460;
    }

    public void drop(){
        y++;
        if (y >= 460){
            y = 460;
        }
    }

    public void step(){
        image = images[index++ / 2 % images.length];
    }

    public void paintPet(Graphics g){
        g.drawImage(image, x, y, WIDTH, HEIGHT, null);
    }

    public void init(){
        images = new Image[6];
        for (int i = 0; i < images.length; i++){
            images[i] = GameUtil.getImage("images/pet/"+ (i+1) +".png");
        }
    }

    public Image getImage() {
        return image;
    }

    public void setImage(Image image) {
        this.image = image;
    }

    public Image[] getImages() {
        return images;
    }

    public void setImages(Image[] images) {
        this.images = images;
    }

    public static int getWIDTH() {
        return WIDTH;
    }

    public static int getHEIGHT() {
        return HEIGHT;
    }

    public Integer getX() {
        return x;
    }

    public void setX(Integer x) {
        this.x = x;
    }

    public Integer getY() {
        return y;
    }

    public void setY(Integer y) {
        this.y = y;
    }

    public Integer getIndex() {
        return index;
    }

    public void setIndex(Integer index) {
        this.index = index;
    }
}
